//
//  RingSubscribeSectionFooter.m
//  BaseProject
//
//  Created by 王洋 on 2021/3/18.
//  Copyright © 2021 王洋. All rights reserved.
//

#import "RingSubscribeSectionFooter.h"

@interface RingSubscribeSectionFooter ()

@property (weak, nonatomic) IBOutlet UIView *bgView;


@property (weak, nonatomic) IBOutlet UIButton *handleBtn;

@property (weak, nonatomic) IBOutlet UIImageView *cancleIcon;
@property (weak, nonatomic) IBOutlet UILabel *cancleReasonLab;

@end

@implementation RingSubscribeSectionFooter


- (void)layoutSubviews {
    [super layoutSubviews];
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        
        [self.handleBtn pp_clipCorners:UIRectCornerAllCorners radius:self.handleBtn.frame.size.height/2];
        [self.bgView pp_clipCorners:UIRectCornerBottomLeft|UIRectCornerBottomRight radius:6];
    });
}

- (void)fillWithModel:(CommonSubscribeRingModel *)model {
    
    self.cancleReasonLab.text = [NSString stringWithFormat:@"取消原因：%@",model.cancelReason];
    
    //领取状态1待领取2已领取3已取消
    switch (model.type) {
        case 1:{
            switch (model.isReceive) {
                case 1:{
                    self.handleBtn.hidden = NO;
                    self.cancleIcon.hidden = YES;
                    self.cancleReasonLab.hidden = YES;
                } break;
                case 2:{
                    self.handleBtn.hidden = YES;
                    self.cancleIcon.hidden = YES;
                    self.cancleReasonLab.hidden = YES;
                } break;
                default:
                    break;
            }
        } break;
        case 2:{
            self.handleBtn.hidden = YES;
            self.cancleIcon.hidden = YES;
            self.cancleReasonLab.hidden = YES;
        } break;
        case 3:{
            self.handleBtn.hidden = YES;
            self.cancleIcon.hidden = NO;
            self.cancleReasonLab.hidden = NO;
        } break;
        default:
            break;
    }
    
}

- (IBAction)footerAction:(id)sender {
    
    if (self.RingSubscribeSectionFooterBlock) {
        self.RingSubscribeSectionFooterBlock(RingSubscribeSectionFooterActionType_cache);
    }
}


@end
